package com.koo.modules.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.koo.common.utils.PageUtils;
import com.koo.common.utils.Query;
import com.koo.modules.base.util.WrapperUtil;
import com.koo.modules.product.dao.ProductStockDao;
import com.koo.modules.product.entity.ProductStockEntity;
import com.koo.modules.product.service.ProductStockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

@Slf4j
@Service
public class ProductStockServiceImpl extends ServiceImpl<ProductStockDao, ProductStockEntity> implements ProductStockService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<ProductStockEntity> wrapper = new QueryWrapper<>();
        WrapperUtil.initQueryWrapper(params, wrapper);
        IPage<ProductStockEntity> page = new Query<ProductStockEntity>().getPage(params);
        page = baseMapper.listByPageWithParams(page, wrapper);
        return new PageUtils(page);
    }

}